package com.yl.panyment.service.impl

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
import com.yl.panyment.common.PayType
import com.yl.panyment.entity.UserPayCallbackLog
import com.yl.panyment.mapper.UserPayCallbackLogMapper
import com.yl.panyment.service.IUserPayCallbackLogService
import org.springframework.stereotype.Service
import java.util.*

@Service
class UserPayCallbackLogServiceImpl(
    private val userPayCallbackLogMapper: UserPayCallbackLogMapper
) : IUserPayCallbackLogService {


    override fun haveSuccess(serviceOrderNum: String,payType: PayType): Boolean {
        val eq = QueryWrapper<UserPayCallbackLog>().eq("service_order_num", serviceOrderNum)
            .eq("deal_status", 1).eq("pay_type",payType.value)
        return userPayCallbackLogMapper.selectCount(eq) == 0
    }

    override fun save(log: UserPayCallbackLog) {
        log.createTime = Date()
        userPayCallbackLogMapper.insert(log)
    }
}